package m202403.d29;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;

/**
 * @@author: 爱做梦的锤子
 * @date: 2024/3/29 19:57
 */
//225. 用队列实现栈
public class Q225 {
    public static class MyStack {

        private Queue<Integer> a;
        private Queue<Integer> b;

        public MyStack() {
            this.a = new LinkedList<>();
            this.b = new LinkedList<>();
        }

        public void push(int x) {
            b.offer(x);
            while (!a.isEmpty()) {
                b.offer(a.poll());
            }
            while (!b.isEmpty()) {
                a.offer(b.poll());
            }
        }

        public int pop() {
            return a.isEmpty() ? -1 : a.poll();
        }

        public int top() {
            return a.isEmpty() ? -1 : a.peek();
        }


        public boolean empty() {
            int b =0;
            return a.isEmpty();
        }


    }
}
